package com.xinruke.hostels.dailymanage.interfaces.enums;

import io.swagger.annotations.ApiModelProperty;

import java.util.Arrays;
import java.util.Comparator;

public enum ECommentScoreDescribe {
    完美("完美", 5.0D),
    非常棒("非常棒", 4.8D),
    很好("很好", 4.4D),
    一般("一般", 0D);
    @ApiModelProperty(value = "评分描述")
    private String describe;

    @ApiModelProperty(value = "评分")
    private Double score;

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    ECommentScoreDescribe() {
    }

    ECommentScoreDescribe(String describe, Double score) {
        this.describe = describe;
        this.score = score;
    }
    public static String getDescribeByScore(Double score){
        //取得比当前分数大的value集合，取最小的
      return Arrays.stream(ECommentScoreDescribe.values())
                .filter(v -> v.getScore().compareTo(score) >= 0)
                .min(Comparator.comparing(ECommentScoreDescribe::getScore))
                .map(ECommentScoreDescribe::getDescribe).orElse("无效评分");

    }



}
